home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-05-03 | 2.2 KB | 92 lines | [TEXT/R*ch] |
- unit SpinningWatch;
-
- interface
-
- {Global variables}
- var
- gWatchHandle: CursHandle;
- gSpinningWatchHandle: array[1..8] of CursHandle;
- gSpinningWatchTimer: LongInt;
- gSpinningWatchState: Integer;
-
- {Call this at the beginning of your program.}
- procedure InitWatch;
-
- {Call ShowWatch as you would InitCursor.}
- procedure ShowWatch;
-
- {This routine is called when we want to first start displaying the moving
- watch cursor.}
- procedure StartSpinningWatch;
-
- {This routine is called when we want to rotate the watch to the next
- position. We should}
- {just call this routine as often as possible; this routine worries about
- the timing itself.}
- procedure SpinWatch;
-
- {This routine deallocates the memory we used and inits the cursor.}
- procedure StopSpinningWatch;
-
- implementation
-
- procedure InitWatch;
- begin
- {Get a handle to that standard watch cursor and hold on to it for the rest
- of the program.}
- gWatchHandle := GetCursor(WatchCursor);
- end;
-
-
- procedure ShowWatch;
- {Set cursor to watch}
- {We have no routine ShowPointer, because we can simply say InitCursor.}
- begin
- SetCursor(gWatchHandle^^);
- end;
-
- {This routine is called when we first start want to display the moving
- watch cursor.}
- procedure StartSpinningWatch;
- var
- counter: Integer;
- begin
- for counter := 1 to 7 do
- gSpinningWatchHandle[counter] := GetCursor(Counter + 256);
- gSpinningWatchState := 8;
- gSpinningWatchTimer := TickCount;
- end;
-
- {This routine is called when we want to rotate the watch to the next
- position. We should}
- {just call this routine as often as possible; this routine worries about
- the timing.}
- procedure SpinWatch;
- var
- NewTime: LongInt;
- begin
- NewTime := TickCount;
- if (NewTime - 30) > gSpinningWatchTimer then
- begin
- gSpinningWatchState := gSpinningWatchState + 1;
- gSpinningWatchTimer := NewTime;
- if gSpinningWatchState > 8 then
- gSpinningWatchState := 1;
- if gSpinningWatchState = 8 then
- ShowWatch
- else
- SetCursor(gSpinningWatchHandle[gSpinningWatchState]^^);
- end;
- end;
-
- {This routine deallocates the memory we used and inits the cursor.}
- procedure StopSpinningWatch;
- var
- counter: Integer;
- begin
- for counter := 1 to 7 do
- ReleaseResource(Handle(gSpinningWatchHandle[counter]));
- end;
-
- end.
-